<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('案件归档列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>案由名称：</label>
                                <input type="text" name="caseName"/>
                            </li>
                            <li>
                                <label>案件类型：</label>
                                <input type="text" name="caseTypeId"/>
                            </li>
                            <li>
                                <label>诉讼类型：</label>
                                <input type="text" name="litigateTypeId"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <input type="hidden" name="status" th:value="${curStatus}"/>
                                <select disabled="true">
				                    <option value="">所有</option>
					      			<option th:each="u:${caseStatus}" th:text="${u.name}" th:value="${u.id}" 
					      			  th:selected="${u.id == curStatus}"></option>
					   			</select>
                            </li>
                            <li>
                                <label>审批人：</label>
                                <input type="text" name="checkUserName"/>
                            </li>
                            <li>
                                <label>审批状态：</label>
                                <select name="checkStatus">
                                    <option value="">所有</option>
                                    <option value="-1">代码生成请选择字典属性</option>
                                </select>
                            </li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
               <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="biz:info:add" th:if="${canAdd == true}">
                    <i class="fa fa-plus"></i> 添加
                </a>
<!--                 <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="biz:info:edit" th:if="${canEdit == true}">
                    <i class="fa fa-edit"></i> 修改
                </a>
 --><!--                 <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="biz:info:remove">
                    <i class="fa fa-remove"></i> 删除
                </a> -->
<!--                 <a class="btn btn-danger multiple disabled" onclick="$.operate.edit()" shiro:hasPermission="biz:info:check" th:if="${canCheck == true}">
                    <i class="fa fa-check"></i> 审批
                </a>
 -->                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="biz:info:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('biz/caseinfo/edit')}]];
        var checkFlag = [[${@permission.hasPermi('biz/caseinfo/check')}]];
        var removeFlag = [[${@permission.hasPermi('biz/caseinfo/remove')}]];
        var viewFlag = [[${@permission.hasPermi('biz/caseinfo/record/view')}]];
        var prefix = ctx + "biz/caseinfo/archived";

        $(function() {
            var options = {
                url: prefix + "/query",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "案件信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'caseId',
                    title: '案件ID',
                    visible: true
                },
                {
                    field: 'caseNo',
                    title: '案件编号'
                },
                {
                    field: 'caseName',
                    title: '案由名称'
                },
                {
                    field: 'caseTypeName',
                    title: '案件类型'
                },
                {
                    field: 'litigateTypeName',
                    title: '诉讼类型'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                    	if (row.status==0) {
                        	return "已登记";
                        } else if (row.status==1) {
                        	return "已立案";
                    	} else if (row.status==2) {
                        	return "进行中";
                    	} else if (row.status==3) {
                        	return "已结案";
                    	} else if (row.status==4) {
                        	return "已归档";
                        } else {
                        	return "初始化";
                        }
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    field: 'checkBy',
                    title: '审批人'
                },
                {
                    field: 'checkStatus',
                    title: '审批',
                    formatter: function(value, row, index) {
                        if (row.checkStatus==1) {
                        	return "已审";
                        /* } else if (row.checkStatus==1) {
                        	return "待结案"; */
                        } else {
                        	return "未审";
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                    	let view = $.common.sprintf("<a class='btn btn-warning btn-xs %s' href='javascript:void(0)' onclick='view(%s)'><i class='fa fa-search'></i>详情</a>&nbsp; ", viewFlag, row.caseId);
                        actions.push(view);
                        let canEdit = [[${canEdit}]];
                        let pushEdit = null;
                        if (canEdit == true) {
                        	pushEdit = $.common.sprintf("<a class='btn btn-success btn-xs %s' href='javascript:void(0)' onclick='$.operate.editTab(%s)'><i class='fa fa-edit'></i>编辑</a>&nbsp; ",
                        		editFlag, row.caseId);
						} else {
							pushEdit = "<label disable='true' readonly><i class='fa fa-edit'></i>编辑</label>&nbsp; ";
                        }
                        actions.push(pushEdit);
                        /* actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.caseId + '\')"><i class="fa fa-remove"></i>删除</a>&nbsp; ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.caseId + '\')"><i class="fa fa-check"></i>审批</a> '); */
/*                          let canCheck = [[${canCheck}]];
                        if (canCheck == true) {
	                        let check = null;
	                        if (row.checkStatus==1) {
	                        	check = "<label disable='true' readonly><i class='fa fa-key'></i>审批</label>&nbsp; ";
	                        } else {
	                        	check = $.common.sprintf("<a class='btn btn-default btn-xs %s' href='javascript:void(0)' onclick='check(%s)'><i class='fa fa-key'></i>审批</a>&nbsp; ", checkFlag, row.caseId);
	                        }
	                        actions.push(check);
                    	}
 */                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        function check(caseId) {
    	    var url = prefix + '/check/' + caseId;
    	    $.modal.openTab("审批案件信息", url);
    	}
        
        function view(caseId) {
    	    var url = prefix + '/view/' + caseId;
    	    $.modal.openTab("查看案件信息", url);
    	}
        
    </script>
</body>
</html>